package com.swt.gap.service.impl;

import com.swt.gap.dao.AchievementTemplateDao;
import com.swt.gap.model.entity.AchievementTemplate;
import com.swt.gap.service.AchievementTemplateService;
import com.swt.gap.util.UserLoginUtils;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @author sx
 */
@Repository
public class AchievementTemplateServiceImpl implements AchievementTemplateService {
    private final AchievementTemplateDao achievementTemplateDao;
    public AchievementTemplateServiceImpl (AchievementTemplateDao achievementTemplateDao) {
        this.achievementTemplateDao = achievementTemplateDao;
    }
    @Override
    public Integer addAchievementTemplate(AchievementTemplate record) {
        record.setCreatedBy(UserLoginUtils.getUserId());
        record.setCreatedTime(new Date());
        return achievementTemplateDao.insertSelective(record);
    }

    @Override
    public List<AchievementTemplate> listAll() {
        return achievementTemplateDao.selectAll();
    }

    @Override
    public AchievementTemplate getAchievementTemplateById(Integer achievementTemplateId) {
        return achievementTemplateDao.selectByPrimaryKey(achievementTemplateId);
    }

    @Override
    public Integer deleteAchievementTemplateById(Integer achievementTemplateId) {
        return achievementTemplateDao.deleteByPrimaryKey(achievementTemplateId);
    }

    @Override
    public Integer updateAchievementTemplateById(AchievementTemplate record) {
        return achievementTemplateDao.updateByPrimaryKeySelective(record);
    }
}
